import Request from 'js_sdk/luch-request/luch-request/index.js'


const getTokenStorage = () => {
	let token = '2'
	// try {
	// 	token = uni.getStorageSync('token')
	// } catch (e) {}
	return token
}


const http = new Request()
http.setConfig((config) => {
	config.baseURL = 'https://wz.mala.cn/' 
	 // config.baseURL = 'http://www.wz1.com/'
	
	config.header = {
		...config.header,
	}
	
	return config
})
 
http.interceptors.request.use((config) => {
	config.data = config.data || {}
	let userInfo = uni.getStorageSync('userInfo')  || {}
	if(userInfo?.auth){
		config.url = config.url + "?token="+encodeURIComponent(userInfo.auth)
	}
	return config
})
http.interceptors.response.use(async (response) => {
	
	return response
}, (response) => {
	// //服务器异常之类的抛出
	// uni.showModal({
	//     title: '提示',
	//     content: '网络异常，请检查网络',
	// 	showCancel:false
	// });
})

export {
	http,
}


